﻿@namespace BootstrapBlazor.Components
@typeparam TItem
@inherits SelectBase<TItem>

@if (ValueExpression != null && DisplayText != null)
{
    <label class="control-label" for="@InputId">@DisplayText</label>
}
<div @attributes="AdditionalAttributes" id="@Id" data-toggle="lgbSelect" class="@ClassName">
    <input type="text" id="@InputId" readonly disabled="@Disabled" class="@InputClassName" data-toggle="dropdown" placeholder="@PlaceHolder" data-original-title="@ErrorMessage" value="@ValueString" @onblur="@OnBlur" />
    <span class="@ArrowClassName"><i class="fa fa-angle-up"></i></span>
    <div class="dropdown-menu-arrow"></div>
    <div class="dropdown-menu">
        @foreach (var itemGroup in GetSelectedItems())
        {
            if (!string.IsNullOrEmpty(itemGroup.Key))
            {
                <Divider Text="@itemGroup.Key" />
            }
            @foreach (var item in itemGroup)
            {
                <div class="@ActiveItem(item)" data-val="@item.Value" @onclick="@(e => OnItemClick(item))">@item.Text</div>
            }
        }
    </div>
</div>
<CascadingValue Value="this" IsFixed="true">
    @ChildContent
</CascadingValue>
